/**
 * 
 */
package Controllers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Event handling class for button events from the GUI.
 * part of a MVC architecture.
 * 
 * @author Danny Johansen, Didzis Petkus, Liviu Berheci.
 * 
 */
public class ButtonController implements ActionListener {

	private Controller parent;

	/**
	 * Constructor with a reference to the main(parent) controller.
	 * @param main - the passed <b>Controller</b> object.
	 */
	public ButtonController(Controller main) {
		parent = main;
	}

	@Override
	public void actionPerformed(ActionEvent ae) {

		if (ae.getActionCommand() != null) {
			if (ae.getActionCommand() == ActionCommand.SEARCH.toString()) {
				parent.searchNXT();
			} else if (ae.getActionCommand() == ActionCommand.STOP_SEARCH
					.toString()) {
				parent.stopSearch();
			} else if (ae.getActionCommand() == ActionCommand.CONNECT
					.toString()) {
				parent.toggleConnection();
			}
		}
	}
	// else if(ae.getActionCommand() == ActionCommand.DISCONNECT.toString())
	// {
	// try {
	// parent.disconnectNXT();
	// } catch (IOException e) {
	// parent.throwDisconnectionError(e);
	// }
	// }

}
